package com.firmail.service.impl;

import com.firmail.mock.util.GsonUtils;
import com.firmail.service.IStdDataProcessService;
import com.google.gson.internal.LinkedTreeMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service
@Qualifier("jsonDataProcessImpl")
@Slf4j
public class JsonDataProcessImpl implements IStdDataProcessService {
    @Override
    public String processData(String json) {

       Object obj= GsonUtils.parseJson(json, Object.class);
       if (obj instanceof LinkedTreeMap) {

           ((LinkedTreeMap) obj).forEach((k, v) -> {
               log.info("LinkedTreeMap: {}= {}", k, v);
           });
       }
        return GsonUtils.toJson(obj);
    }

}
